let vm = new Vue({
    el: '.main-content',
    data: {
        pageInfo: {},
        app: {},
        active: true,
        condition: {
            type: '',
        }

    },
    methods: {
        selectPage: function (pageNum = 1, pageSize = 5) {

            axios({
                url: `mapper/statute/selectPage/${pageNum}/${pageSize}`,
                params: this.condition
            }).then(response => {
                this.pageInfo = response.data.obj;

            }).catch(error => {
                console.log(error.message)
            })
        },
        selectAll: function () {
            this.condition = {
                type: ''
            };
            this.selectPage()
        },
        toUpdate: function (statute) {
            layer.obj = statute;
            layer.open({
                type: 2,      //表示弹出一个iframe
                title: false,  //是否设置标题
                // closeBtn: 0, //不显示关闭按钮
                // shade: [0],
                area: ['90%', '90%'],  //设置子窗口的宽高
                // offset: 'rb', //右下角弹出    //默认中间
                // time: 20000, //20秒后自动关闭
                // anim: 2,
                content: 'mapper/statute/toUpdate', //iframe的url
            })
        },
        insert: function () {
            axios({
                url: "mapper/statute/insert",
                method: "post",
                data: this.app
            }).then(response => {
                if (response.data.success) {
                    //清空
                    this.app = {};
                    //切换
                    this.active = !this.active
                }
                // layer.msg(response.msg("添加成功"))
            }).catch(error => {
                layer.msg(error.message)
            })
        },
        aa: function () {
            this.active = !this.active
        },
        doDelete: function (app) {

            layer.msg('是否删除', {
                time: 20000, //20s后自动关闭
                btn: ['是', '否'],

                yes: () => {
                    //删除标记（0：正常；1：删除；2：审核；）
                    app.delFlag = "1";

                    axios({
                        url: "mapper/statute/doUpdate",
                        method: "post",
                        data: app,

                    }).then(response => {
                        layer.msg(response.data.msg)
                        this.selectPage();//刷新页面
                    }).catch(error => {
                        layer.msg(error.message)
                    });
                }
            });
        }

    },
    created: function () {
        this.selectPage();
    }

});